<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">
			.box{
				width: 400px;
				height: 400px;
				outline: 1px red solid;
				/*position: relative;*/
			}
			#aaa{
				width: 100px;
				height: 100px;
				background: #ccc;
				/*position: absolute;*/
				position: relative;
				top: 200px;
				left: 200px;
			}
		</style>
	</head>
	<body>
		<div class="box">
			<div id="aaa">
								
			</div>
		</div>
		<h4>aaa.offsetWidth、aaa.offsetHeight------获取元素宽高</h4>
		<h4>aaa.offsetLeft、aaa.offsetTop----------获取相对于最近的一个开启定位的父元素的坐标</h4>
		<h4>aaa.offsetParent---------返回最近一个有定位的父元素</h4>
		<h4>aaa.getBoundingClientRect().left--------获取相对浏览器的坐标</h4>
	</body>
</html>
<script type="text/javascript">
	var aaa = document.getElementById('aaa')
	console.log('div宽高：' +aaa.offsetWidth +'-'+aaa.offsetHeight)
	console.log(aaa.offsetParent)
	console.log('相对父元素坐标:' +aaa.offsetLeft +'-'+ aaa.offsetTop)
	console.log('相对浏览器坐标:' + aaa.getBoundingClientRect().left +'-'+ aaa.getBoundingClientRect().top)
</script>